<template>
  <el-container class="home-container">
    <el-header>
      <div>
        <span>厦门理工学院学生德、智、体综合无纸化测评系统</span>
      </div>
<!--      <el-button type="info" @click="logout">安全退出</el-button>-->
      <el-dropdown trigger="click" placement="bottom">
        <div>
      <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" style="margin:10px"></el-avatar>
    </div>

        <el-link type="primary" :underline="false">{{ user.name }}</el-link>
        <el-dropdown-menu style="list-style-type: unset;" slot="dropdown">
          <el-dropdown-item><span @click="logout">安全退出</span></el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>

    <el-container>
      <el-aside :width="iscollapse ? '200px' : '64px'">
        <div class="toggle-butten" @click="toggleColl">|||</div>
        <el-menu background-color="#545c64" text-color="#fff" active-text-color="#409eff" unique-opened
                 :collapse="!iscollapse" :collapse-transition="false" :router="true" :default-active="activePath">
          <el-menu-item :index="item.path" v-for="item in menuList" :key="item.id">
              <i :class="iconsObject[item.id]"></i>
              <span slot="title">{{ item.title }}</span>
          </el-menu-item>
        </el-menu>
      </el-aside>


      <el-main>
        <router-view></router-view>
        <div style="position:relative;bottom:0;color:rgba(0,0,0,.45);margin-top: 1vh;font-family: 华文细黑">@2021 厦门理工学院软件工程学院 | 厦门市熵时光科技有限公司提供技术支持</div>
      </el-main>

    </el-container>

  </el-container>
</template>

<script>
export default {
  name:'Backstage',
  data() {
    return {
      menuList: [
        {id:100,path:'/backstage',title:'综测评分操作' },
        {id:200,path:'/backstage/state',title:'班级管理' }
      ],
      iscollapse: true,
      iconsObject: {
        '100': 'el-icon-menu',
        '200': 'el-icon-user-solid',
        '300': 'el-icon-s-order',
        '400': 'el-icon-film',
      },
      activePath: '/Welconme',
      user:{
        // name:this.$cookieStore.getCookie("username")
        name:'admin'
      }
    }
  },
  beforeCreate() {
    // if (!this.$cookieStore.getCookie('session')){
    //   this.$router.push('/')
    // }
  },
  created() {
    this.activePath = window.sessionStorage.getItem('activePath')
  },
  methods: {
    logout() {
      this.$cookieStore.delCookie("username")
      this.$cookieStore.delCookie("userRole")
      this.$cookieStore.delCookie("userId")
      this.$router.push('/')
    },
    toggleColl() {
      this.iscollapse = !this.iscollapse
    },
    saveNavSate(activePath) {
      window.sessionStorage.setItem('activePath', activePath)
      this.activePath = activePath
    }
  },
}
</script>

<style scoped>
.home-container {
  height: 100vh;
}

.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0%;
  color: #fff;
  font-size: 20px;
  align-items: center;
}
.el-header div {
    display: flex;
    align-items: center;
  }
.el-header span {
      margin-left: 15px;
    }


.el-aside {
  background-color: #333744;

  .el-menu {
    border-right: none;
  }
}

.el-main {
  background-color: #eaedf1;
}

.toggle-butten {
  background-color: #4a5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
